/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package proyectosimulacion;

/**
 *
 * @author Juan Camilo
 */
public class GUI extends javax.swing.JFrame {

    /*
     * Creates new form GUI
     */
    public GUI(){
        initComponents();
        this.setTitle("Semaforos");
        this.setLocation(300, 300);
        txtColaIzq.setEditable(false);
        txtColaDer.setEditable(false);
        txtAutosIzq.setEditable(false);
        txtAutosDer.setEditable(false);
        txtAutosIzq.setText("0");
        txtAutosDer.setText("0");
        txtColaIzq.setText("0");
        txtColaDer.setText("0");
    }
        
    public void cambiarSemaforo(boolean semaforoIzqVerde){
        if (!semaforoIzqVerde){
            semaforoIzq.setText("Rojo");
            semaforoDer.setText("Verde");
            repaint();
        }else{
            semaforoIzq.setText("Verde");
            semaforoDer.setText("Rojo");
            repaint();
        }
    }
    
    public void terminar(){
        semaforoIzq.setText("Rojo");
        semaforoDer.setText("Rojo");
        repaint();
    }
    
    public void esperar(){
        semaforoIzq.setText("Rojo");
        semaforoDer.setText("Rojo");
        //System.out.println("Esperar...");
        repaint();
    }
    
    public void actualizarContadorIzq(int numero){
        txtColaIzq.setText(Integer.toString(numero));
        repaint();
    }
    
    public void actualizarContadorDer(int numero){
        txtColaDer.setText(Integer.toString(numero));
        repaint();
    }
    
    public void actualizarAutosCruzaronIzq(int numero){
        txtAutosIzq.setText(Integer.toString(numero));
        repaint();
    }
    
    public void actualizarAutosCruzaronDer(int numero){
        txtAutosDer.setText(Integer.toString(numero));
        repaint();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        txtColaIzq = new javax.swing.JTextField();
        txtColaDer = new javax.swing.JTextField();
        LblColaIzq = new javax.swing.JLabel();
        LblColaDer = new javax.swing.JLabel();
        semaforoDer = new javax.swing.JLabel();
        semaforoIzq = new javax.swing.JLabel();
        lblAutosIzq = new javax.swing.JLabel();
        lblAutosDer = new javax.swing.JLabel();
        txtAutosIzq = new javax.swing.JTextField();
        txtAutosDer = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        txtColaIzq.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtColaIzqActionPerformed(evt);
            }
        });

        txtColaDer.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtColaDerActionPerformed(evt);
            }
        });

        LblColaIzq.setText("Autos en Cola");

        LblColaDer.setText("Autos en Cola");

        semaforoDer.setText("Rojo");

        semaforoIzq.setText("Rojo");

        lblAutosIzq.setText("# Autos Cruzaron");

        lblAutosDer.setText("# Autos Cruzaron");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(29, 29, 29)
                        .addComponent(txtColaIzq, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(semaforoIzq))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(LblColaIzq)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 131, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(semaforoDer)
                        .addGap(18, 18, 18)
                        .addComponent(txtColaDer, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(40, 40, 40))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(LblColaDer)
                        .addContainerGap())))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(lblAutosIzq)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(lblAutosDer)
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addGap(12, 12, 12)
                        .addComponent(txtAutosIzq, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(txtAutosDer, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(37, 37, 37))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(38, 38, 38)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(LblColaIzq)
                    .addComponent(LblColaDer))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtColaIzq, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtColaDer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(semaforoDer)
                    .addComponent(semaforoIzq))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblAutosIzq)
                    .addComponent(lblAutosDer))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtAutosIzq, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtAutosDer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(32, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void txtColaDerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtColaDerActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtColaDerActionPerformed

    private void txtColaIzqActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtColaIzqActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtColaIzqActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel LblColaDer;
    private javax.swing.JLabel LblColaIzq;
    private javax.swing.JLabel lblAutosDer;
    private javax.swing.JLabel lblAutosIzq;
    private javax.swing.JLabel semaforoDer;
    private javax.swing.JLabel semaforoIzq;
    private javax.swing.JTextField txtAutosDer;
    private javax.swing.JTextField txtAutosIzq;
    private javax.swing.JTextField txtColaDer;
    private javax.swing.JTextField txtColaIzq;
    // End of variables declaration//GEN-END:variables
}
